package ruan_kao;

class Pizza {
    private String parts;

    public void setParts(String parts) {
        this.parts = parts;
    }

    public String toString() {
        return this.parts;
    }
}

abstract class PizzaBuilder {
    protected Pizza pizza;

    public Pizza getPizza() {
        return pizza;
    }

    public void createNewPizza() {
        pizza = new Pizza();
    }

    public abstract void buildParts(); //1
}

class HawaiianPizzaBuilder extends PizzaBuilder {
    public void buildParts() {
        pizza.setParts("cross+mild+ham&pineapple");
    }
}

class SpicyPizzaBuilder extends PizzaBuilder {
    @Override
    public void buildParts() {
        pizza.setParts("pan bakes+hot+pepperroni&salami");
    }
}

class Waiter {
    private PizzaBuilder pizzaBuilder;

    public void setPizzaBuilder(PizzaBuilder pizzaBuilder) {
        this.pizzaBuilder = pizzaBuilder; //2
    }

    public Pizza getPizza() {
        return this.getPizza();
    }

    public void construct() {
        pizzaBuilder.createNewPizza();
        pizzaBuilder.buildParts(); //3
    }
}

class FastFoodOrdering {
    public static void main(String[] args) {
        Waiter waiter = new Waiter();
        PizzaBuilder hawaiian_pizzabuilder = new HawaiianPizzaBuilder();
        waiter.setPizzaBuilder(hawaiian_pizzabuilder); //4
        waiter.construct(); //5
    }
}